# -*- encoding=utf8 -*-
        
__author__ = "Bryan.Chen"
__desc__=""
        
from airtest.core.api import *
        
auto_setup(__file__)
        
from poco.drivers.std import StdPoco
poco = StdPoco()
        
using("../FlowTest.air")
import FlowTest
        
class MiniProgram_GoToMiniProgram(FlowTest.BaseTestCase):
    def __init__(self):
        print("%s __init__" % (__file__))
        
    def runTest(self, args):
        print("%s runTest" % (__file__))

        btnGoToMiniProgram = poco("jumpmini_btn")
        if not btnGoToMiniProgram.exists():
            return False
        
        self.clickButton(btnGoToMiniProgram)

        lblTipsLayer = poco("LBTipsLayer")
        if not lblTipsLayer.exists():
            return False
            
        # 确定进入小程序 
        btnOK = lblTipsLayer.offspring("ok_btn_1")
        self.clickButton(btnOK)

        count = 0
        time1 = time.time()
        while True:
            if exists(Template(r"tpl1534843537579.png", record_pos=(0.244, 0.25), resolution=(1080, 1920))):
                touch(Template(r"tpl1534843537579.png", record_pos=(0.244, 0.25), resolution=(1080, 1920)))
                count = count + 1

                sleep(1.0)
                
                if count == 2:
                    break

                if time.time() - time1 > 1 * 60:
                    break

        sleep(1.0)

        return True
        
_instance = MiniProgram_GoToMiniProgram()
runTest = _instance.runTest


